<?php

namespace app\api\controller\v1;

use app\api\validate\IDCollection;
use app\api\validate\IDMustBePostiveInt;
use app\api\model\Theme as ThemeModel;
use app\lib\exception\ThemeExcption;

class Theme
{
    /*
     * @url /theme?ids=id1,id2,id3...
     * @ruturn 一组theme模型
     * */
    public function getSimpleList($ids = ''){
        (new IDCollection())->goCheck ($ids);
        $theme = ThemeModel::getThemeList ($ids);
        if(!$theme)
            throw new ThemeExcption();
        return $theme;
    }

    /*
     * @url /theme/:id
     * @ruturn 一组theme模型
     * */
    public function getComplexOne($id){
        (new IDMustBePostiveInt())->goCheck ($id);
        $theme = ThemeModel::getThemeWithProducts ($id);
        if(!$theme)
            throw new ThemeExcption();
        return $theme;
    }
}
